package br.com.harley.torneio.persistence;

import java.util.List;

import javax.persistence.Query;

import br.gov.frameworkdemoiselle.stereotype.PersistenceController;
import br.gov.frameworkdemoiselle.template.JPACrud;

@PersistenceController
public abstract class BaseDAO<T, I> extends JPACrud<T, I> {

	private static final long serialVersionUID = 1L;

	public List<T> findByField(String field, Object value) {
		Query query = getEntityManager().createQuery(
				"select b from " + getBeanClass().getName() + " b where b." + field + " = :value");
		query.setParameter("value", value);
		return (List<T>) query.getResultList();
	}

}
